using System;
using System.Xml;
using System.Collections;


namespace ScenarioFramework.Modules.FormHelper
{
	
	public class XMLResources : bOSdotNET.XML.Data.XMLObjectSet
	{
		public const string MAIN_NODE	= "Resources";

		public XMLResources()
		{
			this.Init();
		}

		public XMLResources(System.Xml.XmlNode nodeList)
		{
			this.Parse (nodeList);
		}

		override public void Init()
		{
			this.RemoveAll();
		}

		override public void Parse(System.Xml.XmlNode nodeList)
		{
			this.Init();

			System.Xml.XmlNode node;

			/** find subcollection fileds to add **/
			for ( int i=0; i<nodeList.ChildNodes.Count;i++)
			{
				node = nodeList.ChildNodes[i];

				switch ( node.Name) 
				{
					case XMLResource.PROCESSATTRIBUTE_NODE:
						this.Add ( new XMLResource(node));
						break;
					case XMLResource.DOCUMENT_NODE:
						this.Add ( new XMLResource(node));
						break;
					case XMLResource.SQL_NODE:
						this.Add ( new XMLResource(node));
						break;
					case XMLResource.XSLT_NODE:
						this.Add ( new XMLResource(node));
						break;
				}
			}

		}

		override public bOSdotNET.XML.XMLNode GetXMLNode()
		{
			bOSdotNET.XML.XMLNode XMLNode = new bOSdotNET.XML.XMLNode(XMLResources.MAIN_NODE);

			for ( int i=0; i<this.Count;i++)
			{
				XMLNode.AddNode ( this[i].GetXMLNode() );
			}

			return XMLNode;
		}

	

	}
}
